<?php

class Article extends Component {
	var $params = array (
		'title',
		'content',
		'style',
		'template',
		'editFormTemplate'
	);
	
	public static $actions = array (
		'editForm'
	);
	
	function __construct ($id = false, $params = array ())  {
		$this->id = $id;
		
		$this->title = false;
		$this->content = false;
		$this->style = false;
		$this->template = false;
		$this->editFormTemplate = false;
		
		if ($this->id != false) {
			$this->load ();
		}
		else {
			foreach ($params as $key=>$value) {
				$this->{$key} = $value;
			}
		}
	}

	function createTable () {
		global $dbh;
  
  		$tableName = get_class ($this);
		
		$query = <<<QUERY
CREATE TABLE `{$tableName}` (
  `id` char(32) not null,
  `title` varchar(255) NOT NULL,
  `content` TEXT,
  `style` varchar(50),
  `template` varchar(50),
  `editFormTemplate` varchar(50),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
QUERY;

		$dbh->exec ($query);
				
		return true;
	}
};

?>